package com.hbnu.tangyalu.net;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;

public class UdpSendDemo01 {
    public static void main(String[] args) {
        DatagramSocket datagramSocket=null;
        try {
            datagramSocket=new DatagramSocket();
            String str="zzx";
            byte[] bytes=str.getBytes();                    //数据  数据长度       目的地
            DatagramPacket datagramPacket=new DatagramPacket(bytes,bytes.length, InetAddress.getByName("127.0.0.1"),8888);
            datagramSocket.send(datagramPacket);
        }
        catch (Exception e){
            throw new RuntimeException(e);
        }
    }
}
